<cfsetting enablecfoutputonly="Yes">
<!---
	where/map.cfm
--->

<cfmodule template="_head.cfm" pageTitle="Interactive Map">

<cfoutput>
<style type="text/css">
##map {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
}
body.msie6 ##map {
	width: 100%;
	height: 100%;
}
##searchbox {
	position: absolute;
	z-index: 20;
	margin: 0;
	padding: 0;
	right: 8px;
	top: -1px;
	border: 1px solid ##00cc00;
	background-color: ##ddffdd;
	color: ##009900;
	font-size: 80%;
}
##searchbox input {
	border: 1px solid ##00dd00;
	color: ##009900;
	padding: 0.25em;
	margin: 2px 4px;
	background-color: ##eeeeee;
}
##searchbox input##addr { background-color: ##ffffee; }
##searchbox input##addr:focus {
	background-color: ##ffffaa;
}
##searching {
	display: none;
	margin: 2px 4px;
}
html, body {
	padding: 0 0 0 0;
	margin: 0 0 0 0;
	overflow: hidden;
	width: 100%;
	height: 100%;
}
body {
	background: url(images/spin.gif) 100px 100px no-repeat;
	background-color: white;
}
body.msie6 {
}
</style>
<link rel="stylesheet" type="text/css" href="http://www.google.com/uds/css/gsearch.css"/>
<link rel="stylesheet" type="text/css" href="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css"/>
<script type="text/javascript" language="JavaScript">
//<![CDATA[
var nwsmap;
var lookupid = 0;
var searcher = null;
var results = null;
// var marker = null;
function initialize() {
	if (!GBrowserIsCompatible()) { alert("Sorry, but this application requires a web browser that isn't as old as your mom."); return; }
	document.getElementById('body').style.backgroundImage = 'none';
	nwsmap = new GMap2(document.getElementById("map"));
	nwsmap.setCenter(new GLatLng(38.82259, -95.88867), 4);
	nwsmap.addControl(new GLargeMapControl());
	nwsmap.addControl(new GMapTypeControl());
	GEvent.addListener(nwsmap,"moveend",function() {
		var bounds = nwsmap.getBounds();
		var center = nwsmap.getCenter();
		if((bounds == null) || (center == null)) return false;
		var sw = bounds.getSouthWest();
		var ne = bounds.getNorthEast();
		if((sw == null) || (ne == null)) return false;
		var n = ne.lat();
		var e = ne.lng();
		var w = sw.lng();
		var s = sw.lat();
		var cx = center.lng();
		var cy = center.lat();
		if(isNaN(n) || isNaN(e) || isNaN(w) || isNaN(s) || isNaN(cx) || isNaN(cy)) return false;
		window.parent.getPlaces(cx,cy,n,e,w,s);
	}); // moveend
} // initialize
function updateMap(q, onsuccess, onfail) {
	var geocoder = new GClientGeocoder();
	geocoder.getLatLng(q, function(point) {
		if (!point) {
			if(onfail) { onfail(); }
			else { alert("Could not find: " + q); }
		} else {
			nwsmap.setCenter(point, 13);
			if(onsuccess) { onsuccess(); }
		}
	}); // getLatLng
	return false;
} // updateMap
function toggleSearch(en) {
	document.getElementById('searchentry').style.display = en ? 'block' : 'none';
	document.getElementById('searching').style.display = en ? 'none' : 'block';
} // toggleSearch
function buildThisPlace(point, address) {
	var ret = '<' + 'iframe src="place.cfm?lat=' + escape(point.lat()) + '&lng=' + escape(point.lng()) + '&addr=' + escape(address) + '" width="300" height="200" border="0" frameborder="0" style="border: none;"' + '/' + '>';
	return ret;
} // buildAddPlace
function typeOf(value) {
    var s = typeof value;
    if (s === 'object') {
        if (value) {
            if (value instanceof Array) {
                s = 'array';
            }
        } else {
            s = 'null';
        }
    }
    return s;
} // typeOf
function addLocalSearch() {
	searcher = new google.maps.LocalSearch({
		onSearchCompleteCallback: finishedSearching,
		suppressInitialResultSelection : true,
		resultList : google.maps.LocalSearch.RESULT_LIST_SUPPRESS,
		onMarkersSetCallback: null,
		onIdleCallback: function() {
			lookupid = lookupid + 1;
			if(lookupid > 1) window.parent.clearResults(lookupid);
		},
		onGenerateMarkerHtmlCallback: function(m, n, r) {
			n = document.createElement('IFRAME');
			n.style.border = 'none';
			n.height = 300;
			n.width = 400;
			n.src = 'place.cfm?' + queryFromObject(r,'',/html|url|viewport|class/i);
			return n;
		} // onGenerateMarkerHtmlCallback
	});
	nwsmap.addControl(searcher);
	searcher.focus();
} // addLocalSearch
function queryFromObject(o,pfx,ig) {
	var s = '';
	if(pfx == null) pfx = '';
	var t = typeOf(o);
	if((t == 'string') || (t == 'number') || (t == 'boolean'))
		s += '&' + escape(pfx) + '=' + escape(o);
	else if(t == 'array') {
		for(var j = 0; j < o.length; j++) { // >
			s += queryFromObject(o[j], pfx + '[' + j + ']', ig);
		} // for j
	} // array
	else if(t == 'object') {
		for(var j in o) {
			if(!j.match(ig)) s += queryFromObject(o[j], pfx + (pfx.length ? '.' : '') + j, ig);
		} // for j
	} // object
	return s;
} // obj2qs
function finishedSearching(s) {
	results = s.results;
	lookupid = lookupid + 1;
	window.parent.clearResults(lookupid);
	for(var i=0; i < results.length; i++) { // >
		window.parent.addResult(i, results[i].titleNoFormatting, results[i].lat, results[i].lng, results[i].streetAddress, results[i].phoneNumbers);
	} // for i
	window.parent.finalizeResults();
} // finishedSearching
function openResult(lid, n) {
	if(lid != lookupid) return false;
	if((n == null) || (n < 0) || (n >= searcher.markers.length)) return false;
	var f = document.createElement('IFRAME');
	f.style.border = 'none';
	f.height = 300;
	f.width = 400;
	f.src = 'place.cfm?' + queryFromObject(results[n],'',/html|url|viewport|class/i);
	searcher.markers[n].marker.openInfoWindowHtml(f);
} // openResult
var places = [];
var oldplaces = [];
var placedetail = {};
var overlays = {};
function clearPlaces() {
	while(places.length > 0) {
		oldplaces.push(places[places.length-1]);
		places.pop();
	}
	places = [];
} // clearPlaces
function addPlace(p) {
	if(p == null) return false;
	if(typeOf(p) != 'object') return false;
	if((p.placeid == null) || isNaN(p.lat) || isNaN(p.lng) || (p.title == false)) return false;
	if(places[p.placeid] != null) return true;
	placedetail[p.placeid] = p;
	places.push(p.placeid);
} // addPlace
function showPlaces() {
	setTimeout(showPlaces_, 100);
} // showPlaces
function showPlaces_() {
	var i = 0;
	var placeid = 0;
	var toshow = {};
	for(i = 0; i < places.length; i++) toshow[places[i]] = 1;
	while(oldplaces.length > 0) {
		placeid = oldplaces[oldplaces.length-1];
		if((overlays[placeid] != null) && (toshow[placeid] == null)) {
			nwsmap.removeOverlay(overlays[placeid]);
			overlays[placeid] = null;
		} // if
		oldplaces.pop();
	} // while
	for(i = 0; i < places.length; i++) { // >
		placeid = places[i];
		if(overlays[placeid] != null) continue;
		var d = placedetail[placeid];
		var m = new GMarker(new GLatLng(d.lat, d.lng));
		m.placeid = placeid;
		overlays[placeid] = m;
		nwsmap.addOverlay(m);
		GEvent.addListener(m, "click", showPlace);
	} // for i
} // showPlaces_
function showPlace() {
	if(this.placeid == null) return false;
	if(placedetail[this.placeid] == null) return false;
	var f = document.createElement('IFRAME');
	f.style.border = 'none';
	f.height = 300;
	f.width = 400;
	f.src = 'place.cfm?' + queryFromObject(placedetail[this.placeid],'',/html|url|viewport|class/i);
	this.openInfoWindowHtml(f);
} // showPlace
//]]>
</script>
</head>
<body id="body" class="#Request.Browser.cssClasses()#" onunload="GUnload()" onload="initialize()">
<div id="map"></div>
<script src="http://maps.google.com/maps?file=api&amp;v=2.81&amp;key=#Request.GoogleKey#" type="text/javascript"></script>
<script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&amp;key=#Request.GoogleKey#" type="text/javascript"></script>
<script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js" type="text/javascript"></script>
</cfoutput>

<cfmodule template="_foot.cfm">

<cfsetting enablecfoutputonly="No">